module.exports = function(app) {

    var isLoggedIn = require('../app/util/authUtil').isLoggedIn;
    var simpleUpgradePackageController = require('../app/controller/simpleUpgradePackageController');

    var routes_get = ['toUpload', 'toBatchUpPackage', 'toBindProject', 'downloadZipFile', 'getPackageProject', 'toUpdateTestResult'];
    var routes_post = ['query', 'queryPackageProjects', 'doUpload', 'doBatchUpPackage', 'doUpdateTestStatu', 'doBindProject', 'publish', 'remove', 'doUpdateTestResult'];

    /**
     * 首页
     */
    app.get('/simpleUpgradePackage', isLoggedIn);
    app.get('/simpleUpgradePackage', function(req, res) {
        res.render('simpleUpgradePackage/index');
    });

    for (var i = 0; i < routes_get.length; i++) {
        (function(_routeName) {
            app.get('/simpleUpgradePackage/' + _routeName, isLoggedIn);
            app.get('/simpleUpgradePackage/' + _routeName, function(req, res) {
                simpleUpgradePackageController[_routeName](req, res);
            });
        }(routes_get[i]));
    }

    for (var i = 0; i < routes_post.length; i++) {
        (function(_routeName) {
            app.post('/simpleUpgradePackage/' + _routeName, isLoggedIn);
            app.post('/simpleUpgradePackage/' + _routeName, function(req, res) {
                simpleUpgradePackageController[_routeName](req, res);
            });
        }(routes_post[i]));
    }

};